export default {
  watch: {
    projectId: function (newProjectId) {
      this.getPage(1,10);
    }
  },
  computed: {
    projectId: function () {
      return this.$store.getters.getProjectId;
    },
  },
  name: "index",
  mounted() {
    this.getPage(1,10);
  },
  data(){
    return{
      input: "",
      groupIds:[],
      groupList:[],
      envId:"",
      envList:[],
      jobPlanList:{
        data:{
          list: [
            {
              id:"",
            }
          ],
          pageNumber:0,
          pageSize:0,
        }
      },
      ta: 50,
      status:[
        {
          id:1,
          name:"执行成功"
        },{
          id:0,
          name:"进行中"
        },{
          id:2,
          name:"执行失败"
        }
      ],
      dialogFormVisible: false,
      name: "",
      remark: "",
      formLabelWidth: "100px",

    }
  },
  methods:{
    search() {
    },
    getStatus(row,column){
      if (row.status==0){
        return "进行中"
      }else if (row.status==1) {
        return "执行成功"
      }else if (row.status==2){
        return "执行失败"
      }else if (row.status==3){
        return "执行异常"
      }
    },
    formatter(row, column) {
      return this.$dateFomat.timestampToTime(row.createTime * 1000);
    },
    getPage(pageNum, pageSize){
      this.$jobPlan
        .page({
          pageNum: pageNum,
          pageSize: pageSize,
          projectId: this.$store.getters.getProjectId
        })
        .then((res) => {
          if (res.code == 200) {
            this.jobPlanList = res;
          } else {
          }
        })
        .catch((res) => {
          console.log(res);
        });
    },
    cz() {
      this.input = "";
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.getPage(1,val)
    },
    handleCurrentChange(val) {
      this.getPage(val,this.jobPlanList.data.pageSize)
    },
    getDetail(index) {
      var id = this.jobPlanList.data.list[index].id;
      console.log(id);
      this.$router.push({ path: "/reportDetail", query: { id: id } });
    },
    handleDelete(index) {
      var id = this.jobPlanList.data.list[index].id;
      this.$job
        .jobDelete({ id: id })
        .then((res) => {
          console.log(res);
          this.getJobPage(this.jobPlanList.data.pageNum,this.jobPlanList.data.pageSize);
        })
        .catch((res) => {
          console.log(res);
        });
    },
  }
}
